(此篇會再加上描述)
var array = ['a', 'b', 'c'];
array.forEach(function(item, index, array){
console.log(item, index, array));
}
const array = [1, 4, 9, 16];
const map = array.map(x => x * 2);
console.log(map); // [2, 8, 18, 32]
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result); // ["exuberant", "destruction", "present"]
const array1 = [5, 12, 8, 130, 44];
const found = array1.find(element => element > 10);
console.log(found); // 12
const isBelowThreshold = (currentValue) => currentValue < 40;
const array1 = [1, 30, 39, 29, 10, 13];
console.log(array1.every(isBelowThreshold)); // true
const array = [1, 2, 3, 4, 5];
const even = (element) => element % 2 === 0;
console.log(array.some(even)); // true
const array1 = [1, 2, 3, 4];
const reducer = (accumulator, currentValue) => accumulator + currentValue;
// 1 + 2 + 3 + 4
console.log(array1.reduce(reducer)); // 10
// 5 + 1 + 2 + 3 + 4
console.log(array1.reduce(reducer, 5)); // 15